]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
init: Improve error message formatting
authorPhilip Chimento <philip.chimento@gmail.com>
Mon, 1 Jan 2024 00:13:25 +0000 (19:13 -0500)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 4 Jan 2024 18:59:33 +0000 (18:59 +0000)
Instead of manually formatting the error message and stack, use the same
formatting mechanism as we do when displaying errors to the user that
occur while opening extension preferences. This should correctly
indicate where syntax errors from imported modules occur.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3041>

js/ui/init.js

index a7cf7db3e90470f7fb940f0bb1b1c9fc8ee7166f..735a367bbeb1f00ea11ea87576f8167ad6f72d88 100644 (file)
@@ -2,6 +2,7 @@ import GLib from 'gi://GLib';
 import Gio from 'gi://Gio';
 
 import './environment.js';
+import {formatError} from '../misc/errorUtils.js';
 
 // Run the Mutter main loop after
 // GJS finishes resolving this module.
@@ -10,8 +11,7 @@ imports._promiseNative.setMainLoopHook(() => {
     GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
         import('./main.js').then(main => main.start()).catch(e => {
             const error = new GLib.Error(
-                Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED,
-                `${e.message}\n${e.stack}`);
+                Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED, formatError(e));
             global.context.terminate_with_error(error);
         });
         return GLib.SOURCE_REMOVE;